<!--# layout("/common/layout.html",{"jsBase":"/js/customer/customerInfo/"}){ -->

<form class="layui-form layui-form-pane" id="theForm" lay-filter="editform" name="theForm">
    <input type="hidden" name="customerId" id="customerId" value="${customerId}">
    <div class="layui-row">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">VIP类型</label>
                <div class="layui-input-inline">
                    <layui:simpleDataSelect name="roleId" id="roleId" data="${roleList}"
                                            attrId="roleId" attrName="roleName"/>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">高考年份</label>
                <div class="layui-input-inline">
                    <select name="choiceYear">
                    <option value="">请选择</option>
                    <option value="${year}">${year}</option>
                    <option value="${year+1}">${year+1}</option>
                    <option value="${year+2}">${year+2}</option>
                    </select>
                </div>
            </div>
        </div>
    </div>

    <layui:submitButtons id="addButton" />

</form>
<!--#} -->
<script>
    layui.define([ 'form', 'laydate', 'table','customerInfoApi'], function(exports) {
        var form = layui.form;
        var customerInfoApi = layui.customerInfoApi;
        var view = {
            init:function(){
                Lib.initGenrealForm($("#theForm"),form);
                this.initSubmit();
            },
            initSubmit:function(){
                $("#addButton").click(function(){
                    form.on('submit(form)', function(){
                        var formVal = form.val("editform");
                        console.log(formVal);
                        if (!("roleId" in formVal) || formVal.roleId=="") {
                            Common.alert("必须选择VIP类型！",2);
                            return false;
                        }

                        if (!("choiceYear" in formVal) || formVal.choiceYear=="") {
                            Common.alert("必须选择高考年份！",2);
                            return false;
                        }
                        customerInfoApi.grantCustomerForm($('#theForm'),function(){
                            parent.window.dataReload();
                            Common.info("授权成功。");
                            Lib.closeFrame();
                        });
                    });
                });

                $("#addButton-cancel").click(function(){
                    Lib.closeFrame();
                });

            }

        }
        view.init();
    });
</script>